home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS01.ADF
/
C
/
decvnt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-11-16
|
2KB
|
80 lines
/* decvnt.c */
/****************************************************************/
/* */
/* program to reverse the operation of "convert" for the Amiga */
/* used to counteract the effect of BBS systems which can't take*/
/* binary files */
/* This program was originally compiled by Microsoft C 3.0 */
/* compile as: msc decnvt; */
/* link as: link decnvt+\msc\lib\binmode; */
/* */
/* Copyright(c) 1985 Michael G. Lehman */
/* Freely distribute but All Rights still reserved */
/* */
/****************************************************************/
/* converted to Lattice by John Foust, the AMICUS Network */
/* define one of these */
#define LATTI
#undef MSC30
#include <stdio.h>
#include <fcntl.h>
#ifdef MSC30
#include <sys\types.h>
#include <sys\stat.h>
#include <io.h>
#endif
char buf[256];
unsigned char bytes[128];
FILE *in;
int out;
main(argc,argv)
int argc;
char **argv;
{
int i,j;
char *p;
in = fopen(argv[1],"r");
#ifdef MSC30
out= open(argv[2],O_TRUNC | O_WRONLY | O_BINARY | O_CREAT , S_IWRITE);
#endif
#ifdef LATTI
out= open(argv[2],O_TRUNC | O_WRONLY | O_RAW | O_CREAT );
#endif
while(1)
{
fread(buf,sizeof(buf),1,in);
for(i=0,j=0; buf[i] != '\n' && buf[i] != 'Q' && i < sizeof(buf); i++)
{
bytes[j] = (cnv(buf[i++]) << 4);
bytes[j++] |= cnv(buf[i]);
}
write(out,bytes,j);
if (buf[i] == 'Q')
break;
}
fclose(in);
close(out);
}
int cnv(ch)
char ch;
{
if (ch >= '0' && ch <= '9')
return(ch-'0');
else
return((ch-'A')+10);
}